Integration
In this lesson, we will learn about definite and indefinite integrals of single and multiple integrations.
We'll cover the following
Integration is one of the two main operations of calculus, with its inverse operation, differentiation, being the other. Given a function of a real variable and an interval of the real line, the definite integral is denoted as:
Integrals are calculated with the integrate() function. SymPy implements a combination of the Risch algorithm and an algorithm for computing integrals based on Meijer G-functions. These allow SymPy to compute a wide variety of indefinite and definite integrals.
Indefinite integrals#
Integration uses syntax similar to differentiation. For the indefinite integral, we specify the function and the variable with respect to which the integration is performed.
integrate(y, x)
The
integrate()function does not add the constant of integration in the indefinite integral.
Let’s see an example of integrating a polynomial below:
SymPy allows for a range of integrals. Let’s see them one by one
Rational
Trigonometric
Logarithmic and Exponential
Definite integral#
Definite integrals can be computed by providing a tuple having the variable of integration, and the limits of integration:
integrate(y, (x, lowerBound, upperBound))
For improper integrals, we use the
oosymbol for infinite.
Proper Integral
Let’s look at its implementation in SymPy:
Improper Integral
Let’s see its implementation in SymPy:
Multiple integrals#
Multiple integrals are essential when dealing with vector calculus and are a stepping stone for solving many 2-D and 3-D problems in science.
Multiple integrals can be performed by specifying several variables when the integration is performed.
Indefinite Integrals
For indefinite integrals, we use the following syntax:
integrate(f(x, y, z), x, y, z)
In the given code, the function would be integrated over x, first, then over y, then over z.
Definite Integrals
For definite integrals, we usually use tuples (we could also use lists) for providing limits of integration:
integrate(f(x, y, z), (x, lower_x, upper_x), (y, lower_y, upper_y), (z, lower_z, upper_z))
Let’s see it’s implementation below:
Let’s learn about limits in the next lesson.
Differentiation
Limits